home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!sun-barr!ames!pasteur!nntp
- From: scott.oaks@East.Sun.COM (Scott Oaks)
- Newsgroups: comp.sources.x
- Subject: v15i165: OpenLook Virtual Window Mgr (3.0), Part19/21
- Message-ID: <1992Feb4.140047.8312@pasteur.Berkeley.EDU>
- Date: 4 Feb 92 14:00:47 GMT
- References: <csx-15i147-olvwm-3.0@uunet.UU.NET>
- Sender: dcmartin@msi.com (David C. Martin - Moderator)
- Organization: University of California, at Berkeley
- Lines: 2194
- Approved: dcmartin@msi.com
- Nntp-Posting-Host: postgres.berkeley.edu
-
- Submitted-by: scott.oaks@East.Sun.COM (Scott Oaks)
- Posting-number: Volume 15, Issue 165
- Archive-name: olvwm-3.0/part19
-
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # If this archive is complete, you will see the following message at the end:
- # "End of archive 19 (of 21)."
- # Contents: atom.c cmdstream.c group.c resources.h st.c winmenu.c
- # winnofoc.c winresize.c
- # Wrapped by dcmartin@fascet on Tue Jan 14 05:54:48 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'atom.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'atom.c'\"
- else
- echo shar: Extracting \"'atom.c'\" \(6058 characters\)
- sed "s/^X//" >'atom.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)atom.c 26.17 91/09/14 SMI"
- X
- X#include <X11/Xlib.h>
- X#include <X11/Xatom.h>
- X#include <X11/Xresource.h>
- X
- XAtom AtomAtomPair;
- XAtom AtomChangeState;
- XAtom AtomClass;
- XAtom AtomColorMapWindows;
- XAtom AtomDecorAdd;
- XAtom AtomDecorClose;
- XAtom AtomDecorDel;
- XAtom AtomDecorFooter;
- XAtom AtomDecorHeader;
- XAtom AtomDecorPin;
- XAtom AtomDecorResize;
- XAtom AtomDelete;
- XAtom AtomDeleteWindow;
- XAtom AtomDfltBtn;
- XAtom AtomLeftFooter;
- XAtom AtomLength;
- XAtom AtomListLength;
- XAtom AtomMenuFull;
- XAtom AtomMenuLimited;
- XAtom AtomMultiple;
- XAtom AtomName;
- XAtom AtomNone;
- XAtom AtomOlwmTimestamp;
- XAtom AtomPinIn;
- XAtom AtomPinOut;
- XAtom AtomProtocols;
- XAtom AtomPushpinState;
- XAtom AtomRightFooter;
- XAtom AtomSaveYourself;
- XAtom AtomShowProperties;
- XAtom AtomSunViewEnv;
- XAtom AtomTakeFocus;
- XAtom AtomTargets;
- XAtom AtomTimestamp;
- XAtom AtomUser;
- XAtom AtomWMClass;
- XAtom AtomWMName;
- XAtom AtomWMIconName;
- XAtom AtomWMHints;
- XAtom AtomWMNormalHints;
- XAtom AtomWMSizeHints;
- XAtom AtomWMTransientFor;
- XAtom AtomWMApplyProperties;
- XAtom AtomWMResetProperties;
- XAtom AtomWMState;
- XAtom AtomWTBase;
- XAtom AtomWTCmd;
- XAtom AtomWTHelp;
- XAtom AtomWTNotice;
- XAtom AtomWTOther;
- XAtom AtomWinAttr;
- XAtom AtomWindowBusy;
- XAtom AtomSunLedMap;
- XAtom AtomSunWMProtocols;
- XAtom AtomSunWindowState;
- XAtom AtomSunDragDropInterest;
- XAtom AtomSunOLWinAttr5;
- XAtom AtomDecorIconName;
- X
- X/***************************************************************************
- X* Global functions
- X***************************************************************************/
- X
- X/*
- X * InitAtoms -- initialize the atoms needed to communicate with Open
- X * Look clients
- X */
- XInitAtoms(dpy)
- XDisplay *dpy;
- X{
- X /* ICCCM specific flags */
- X AtomColorMapWindows = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
- X AtomWMState = XInternAtom(dpy, "WM_STATE", False);
- X AtomChangeState = XInternAtom(dpy, "WM_CHANGE_STATE" , False);
- X AtomProtocols = XInternAtom(dpy, "WM_PROTOCOLS" , False);
- X AtomTakeFocus = XInternAtom(dpy, "WM_TAKE_FOCUS" , False);
- X AtomSaveYourself = XInternAtom(dpy, "WM_SAVE_YOURSELF" , False);
- X AtomDeleteWindow = XInternAtom(dpy, "WM_DELETE_WINDOW" , False);
- X
- X /* Predefined atoms - referenced from ClientDistributeProperties */
- X AtomWMName = XA_WM_NAME;
- X AtomWMIconName = XA_WM_ICON_NAME;
- X AtomWMClass = XA_WM_CLASS;
- X AtomWMHints = XA_WM_HINTS;
- X AtomWMNormalHints = XA_WM_NORMAL_HINTS;
- X AtomWMSizeHints = XA_WM_SIZE_HINTS;
- X AtomWMTransientFor = XA_WM_TRANSIENT_FOR;
- X
- X /* OpenLook specific flags */
- X AtomWinAttr = XInternAtom(dpy, "_OL_WIN_ATTR" , False);
- X AtomPushpinState = XInternAtom(dpy, "_OL_PIN_STATE" , False);
- X AtomWindowBusy = XInternAtom(dpy, "_OL_WIN_BUSY" , False);
- X AtomLeftFooter = XInternAtom(dpy, "_OL_WINMSG_ERROR" , False);
- X AtomRightFooter = XInternAtom(dpy, "_OL_WINMSG_STATE" , False);
- X AtomShowProperties = XInternAtom(dpy, "_OL_SHOW_PROPS" , False);
- X AtomWMApplyProperties = XInternAtom(dpy, "_OL_PROPS_APPLY" , False);
- X AtomWMResetProperties = XInternAtom(dpy, "_OL_PROPS_RESET" , False);
- X AtomPinOut = XInternAtom(dpy, "_OL_PIN_OUT" , False);
- X AtomDecorResize = XInternAtom(dpy, "_OL_DECOR_RESIZE" , False);
- X AtomWTBase = XInternAtom(dpy, "_OL_WT_BASE" , False);
- X AtomDecorFooter = XInternAtom(dpy, "_OL_DECOR_FOOTER" , False);
- X AtomDecorAdd = XInternAtom(dpy, "_OL_DECOR_ADD" , False);
- X AtomDecorDel = XInternAtom(dpy, "_OL_DECOR_DEL" , False);
- X AtomDecorPin = XInternAtom(dpy, "_OL_DECOR_PIN" , False);
- X AtomWTCmd = XInternAtom(dpy, "_OL_WT_CMD" , False);
- X AtomPinIn = XInternAtom(dpy, "_OL_PIN_IN" , False);
- X AtomNone = XInternAtom(dpy, "_OL_NONE" , False);
- X AtomWTNotice = XInternAtom(dpy, "_OL_WT_NOTICE" , False);
- X AtomMenuFull = XInternAtom(dpy, "_OL_MENU_FULL" , False);
- X AtomDecorHeader = XInternAtom(dpy, "_OL_DECOR_HEADER" , False);
- X AtomWTHelp = XInternAtom(dpy, "_OL_WT_HELP" , False);
- X AtomMenuLimited = XInternAtom(dpy, "_OL_MENU_LIMITED" , False);
- X AtomDecorClose = XInternAtom(dpy, "_OL_DECOR_CLOSE" , False);
- X AtomWTOther = XInternAtom(dpy, "_OL_WT_OTHER" , False);
- X AtomOlwmTimestamp = XInternAtom(dpy,"_OLWM_TIMESTAMP",False);
- X AtomDfltBtn = XInternAtom(dpy, "_OL_DFLT_BTN", False);
- X AtomDecorIconName = XInternAtom(dpy, "_OL_DECOR_ICON_NAME", False);
- X
- X /* ICCCM selection atoms */
- X AtomAtomPair = XInternAtom(dpy,"ATOM_PAIR",False);
- X AtomClass = XInternAtom(dpy,"CLASS",False);
- X AtomDelete = XInternAtom(dpy,"DELETE",False);
- X AtomMultiple = XInternAtom(dpy,"MULTIPLE",False);
- X AtomLength = XInternAtom(dpy,"LENGTH",False);
- X AtomListLength = XInternAtom(dpy,"LIST_LENGTH",False);
- X AtomName = XInternAtom(dpy,"NAME",False);
- X AtomTargets = XInternAtom(dpy,"TARGETS",False);
- X AtomTimestamp = XInternAtom(dpy,"TIMESTAMP",False);
- X AtomUser = XInternAtom(dpy,"USER",False);
- X
- X /* SunView environment */
- X AtomSunViewEnv = XInternAtom(dpy,"_SUN_SUNVIEW_ENV",False);
- X
- X /* Sun window manager atoms */
- X AtomSunLedMap = XInternAtom(dpy,"_SUN_LED_MAP",False);
- X AtomSunWMProtocols = XInternAtom(dpy,"_SUN_WM_PROTOCOLS",False);
- X AtomSunWindowState = XInternAtom(dpy,"_SUN_WINDOW_STATE",False);
- X AtomSunOLWinAttr5 = XInternAtom(dpy,"_SUN_OL_WIN_ATTR_5",False);
- X
- X AtomSunDragDropInterest =
- X XInternAtom(dpy, "_SUN_DRAGDROP_INTEREST", False);
- X}
- X
- X#ifdef notdef
- X/* XXX remove after properties.c working */
- Xvoid *
- XGetWindowProperty(dpy, w, property, long_offset, long_length, req_type,
- X req_fmt, nitems, bytes_after)
- XDisplay *dpy;
- XWindow w;
- XAtom property;
- Xlong long_offset, long_length;
- XAtom req_type;
- Xint req_fmt;
- Xunsigned long *nitems;
- Xunsigned long *bytes_after;
- X{
- X int status;
- X unsigned char *prop;
- X Atom act_type;
- X int act_format;
- X
- X status = XGetWindowProperty(dpy, w, property, long_offset, long_length,
- X False, req_type, &act_type, &act_format, nitems,
- X bytes_after, &prop);
- X if ((status != Success) || (act_type != req_type))
- X {
- X *nitems = 0;
- X return NULL;
- X }
- X if ((req_fmt != 0) && (act_format != req_fmt))
- X {
- X XFree((char *)prop);
- X *nitems = 0;
- X return NULL;
- X }
- X return (void *)prop;
- X}
- X#endif
- END_OF_FILE
- if test 6058 -ne `wc -c <'atom.c'`; then
- echo shar: \"'atom.c'\" unpacked with wrong size!
- fi
- # end of 'atom.c'
- fi
- if test -f 'cmdstream.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'cmdstream.c'\"
- else
- echo shar: Extracting \"'cmdstream.c'\" \(6016 characters\)
- sed "s/^X//" >'cmdstream.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X/* ----------------------------------------------------------------------
- X * cmdstream.c
- X * ---------------------------------------------------------------------*/
- X
- X#ident "@(#)cmdstream.c 26.6 91/09/14 SMI"
- X
- X#include <stdio.h>
- X#ifdef SYSV
- X#include <string.h>
- X#else
- X#include <strings.h>
- X#endif
- X#include "cmdstream.h"
- X#include "mem.h"
- X
- Xextern char *strtok();
- X
- X/* ----------------------------------------------------------------------
- X * Local Data Structures
- X * ---------------------------------------------------------------------*/
- X
- Xtypedef struct _CList {
- X Command *this;
- X struct _CList *next;
- X} CList;
- X
- Xtypedef struct _CmdInfo {
- X FILE *input;
- X FILE *output;
- X CList *cmdListHead;
- X} CmdInfo;
- X
- X/* ----------------------------------------------------------------------
- X * Data Definitions
- X * ---------------------------------------------------------------------*/
- X
- Xstatic CmdInfo cmdInfo = {
- X (FILE *)0, (FILE *)0, (CList *)0
- X};
- X
- X/* ----------------------------------------------------------------------
- X * Local Forward Declarations
- X * ---------------------------------------------------------------------*/
- X
- XCommand *MatchCommand();
- XCmdAttr *MatchAttr();
- Xint EncodeAttrValue();
- Xint DecodeAttrValue();
- X
- X/* ----------------------------------------------------------------------
- X * SetCmdStream
- X * ---------------------------------------------------------------------*/
- Xvoid
- XSetCmdStream(instream,outstream)
- X FILE *instream;
- X FILE *outstream;
- X{
- X cmdInfo.input = instream;
- X cmdInfo.output = outstream;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * SendCmd
- X * ---------------------------------------------------------------------*/
- Xint
- XSendCmd(cmd)
- X Command *cmd;
- X{
- X CmdAttr *attr;
- X int i;
- X
- X if (cmdInfo.output == (FILE *)NULL)
- X return FALSE;
- X
- X fprintf(cmdInfo.output,"%s\n",cmd->keyword);
- X for (i=0; i<cmd->attrLen; i++) {
- X attr = &(cmd->attrList[i]);
- X fprintf(cmdInfo.output,"\t%s=",attr->name);
- X EncodeAttrValue(attr,cmdInfo.output);
- X fputs("\n",cmdInfo.output);
- X }
- X fputs(";\n",cmdInfo.output);
- X fflush(cmdInfo.output);
- X return TRUE;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * RegisterCmd
- X * ---------------------------------------------------------------------*/
- Xvoid
- XRegisterCmd(cmd)
- X Command *cmd;
- X{
- X CList *item;
- X
- X item = MemNew(CList);
- X item->this = cmd;
- X item->next = cmdInfo.cmdListHead;
- X cmdInfo.cmdListHead = item;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * GetCmd
- X * ---------------------------------------------------------------------*/
- Xint
- XGetCmd()
- X{
- X#define CMDBUFLEN 1024
- X char cmdBuf[CMDBUFLEN];
- X
- X while (fgets(cmdBuf,CMDBUFLEN,cmdInfo.input) != (char *)NULL) {
- X if (ParseCmd(cmdBuf) == FALSE)
- X return FALSE;
- X }
- X return TRUE;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * ParseCmd
- X * ---------------------------------------------------------------------*/
- Xint
- XParseCmd(line)
- X char *line;
- X{
- X char *token;
- X char *sep = " \t\n";
- X static Command *cmd = (Command *)NULL;
- X static CmdAttr *attr = (CmdAttr *)NULL;
- X
- X for (token=strtok(line,sep); token; token=strtok(0,sep)) {
- X if (cmd == (Command *)NULL) {
- X if ((cmd = MatchCommand(token)) == (Command *)NULL)
- X return FALSE;
- X } else if (token[0] == ';') {
- X if (cmd->callback)
- X (*cmd->callback)(cmd);
- X cmd = (Command *)NULL;
- X attr = (CmdAttr *)NULL;
- X } else {
- X if ((attr = MatchAttr(cmd,token)) == (CmdAttr *)NULL) {
- X cmd = (Command *)NULL;
- X return FALSE;
- X }
- X }
- X }
- X return FALSE;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * MatchKeyword
- X * ---------------------------------------------------------------------*/
- Xstatic Command *
- XMatchCommand(keyword)
- X char *keyword;
- X{
- X CList *item;
- X
- X for (item=cmdInfo.cmdListHead; item; item=item->next) {
- X if (!strcmp(keyword,item->this->keyword)) {
- X return item->this;
- X }
- X }
- X return (Command *)NULL;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * MatchAttr
- X * ---------------------------------------------------------------------*/
- Xstatic CmdAttr *
- XMatchAttr(cmd,name)
- X Command *cmd;
- X char *name;
- X{
- X int i,equalindex;
- X char *equalpos;
- X char *strchr();
- X
- X equalpos = strchr(name,'=');
- X
- X if (!equalpos)
- X return (CmdAttr *)NULL;
- X
- X equalindex = equalpos - name;
- X
- X for (i=0; i<cmd->attrLen; i++) {
- X if (!strncmp(name,cmd->attrList[i].name,equalindex)) {
- X if (!DecodeAttrValue(&cmd->attrList[i],++equalpos))
- X return (CmdAttr *)NULL;
- X return &(cmd->attrList[i]);
- X }
- X }
- X return (CmdAttr *)NULL;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * EncodeAttrValue
- X * ---------------------------------------------------------------------*/
- Xstatic int
- XEncodeAttrValue(attr,stream)
- X CmdAttr *attr;
- X FILE *stream;
- X{
- X switch (attr->type) {
- X case INT: fprintf(stream,"%d",attr->value.ival);
- X break;
- X case FLOAT: fprintf(stream,"%f",attr->value.fval);
- X break;
- X case STRING: fprintf(stream,"%s",attr->value.sval);
- X break;
- X }
- X return TRUE;
- X}
- X
- X/* ----------------------------------------------------------------------
- X * DecodeAttrValue
- X * ---------------------------------------------------------------------*/
- Xstatic int
- XDecodeAttrValue(attr,valuestr)
- X CmdAttr *attr;
- X char *valuestr;
- X{
- X char *ptr;
- X int status = TRUE;
- X
- X switch (attr->type) {
- X case INT: attr->value.ival = (int)strtol(valuestr,&ptr,10);
- X if (ptr == valuestr)
- X status = FALSE;
- X break;
- X case FLOAT: attr->value.fval = (float)strtod(valuestr,&ptr);
- X if (ptr == valuestr)
- X status = FALSE;
- X break;
- X case STRING: attr->value.sval = MemNewString(valuestr);
- X if (attr->value.sval == (char *)NULL)
- X status = FALSE;
- X break;
- X default:
- X status = FALSE;
- X break;
- X }
- X return status;
- X}
- END_OF_FILE
- if test 6016 -ne `wc -c <'cmdstream.c'`; then
- echo shar: \"'cmdstream.c'\" unpacked with wrong size!
- fi
- # end of 'cmdstream.c'
- fi
- if test -f 'group.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'group.c'\"
- else
- echo shar: Extracting \"'group.c'\" \(6503 characters\)
- sed "s/^X//" >'group.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)group.c 26.7 91/09/14 SMI"
- X
- X#include <stdio.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include "i18n.h"
- X#include "mem.h"
- X#include "st.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "list.h"
- X#include "group.h"
- X
- X/***************************************************************************
- X* Local data
- X***************************************************************************/
- X
- Xstatic st_table *groupHashTable;
- X
- X/***************************************************************************
- X* Local functions
- X***************************************************************************/
- X
- X/* groupFindList -- find a client in a list of clients; return a given
- X * value if found or 0 otherwise. If passed a pointer to a List **, set that.
- X */
- Xstatic unsigned int
- XgroupFindList(plist, cli, retlist, retval)
- XList **plist;
- XClient *cli;
- XList ***retlist;
- Xunsigned int retval;
- X{
- X if ((cli == NULL) || (*plist == NULL))
- X {
- X if (retlist != NULL)
- X *retlist = NULL;
- X return 0;
- X }
- X
- X if ((*plist)->value == cli)
- X {
- X if (retlist != NULL)
- X *retlist = plist;
- X return retval;
- X }
- X return groupFindList(&((*plist)->next), cli, retlist, retval);
- X}
- X
- X
- X/* groupFindCli -- find a client in a group. Return a mask indicating
- X * which category of client the client was found in, if any; if a list
- X * pointer is passed in, return a pointer to a List * in that parameters
- X * (presumably for list deletion).
- X */
- Xstatic unsigned int
- XgroupFindCli(group, cli, ppList)
- XGroup *group;
- XClient *cli;
- XList ***ppList;
- X{
- X unsigned int retmask;
- X
- X if (cli == group->leader)
- X {
- X retmask = GROUP_LEADER;
- X }
- X else
- X {
- X if ((retmask = groupFindList(&(group->dependents), cli, ppList,
- X GROUP_DEPENDENT)) == 0)
- X retmask = groupFindList(&(group->independents), cli, ppList,
- X GROUP_INDEPENDENT);
- X }
- X return retmask;
- X}
- X
- X/* groupCompare -- utility function to compare two group id's
- X */
- Xstatic int
- XgroupCompare(g1,g2)
- Xregister char *g1, *g2;
- X{
- X return ((GroupID)g1) - ((GroupID)g2);
- X}
- X
- X/* groupHash -- hash function for group id lookup table
- X */
- Xstatic int
- XgroupHash(g1, modulus)
- Xregister char *g1;
- Xregister int modulus;
- X{
- X return ((GroupID)g1)%modulus;
- X}
- X
- X/* groupInsert -- put a group structure into the lookup table
- X */
- Xstatic void
- XgroupInsert(group)
- XGroup *group;
- X{
- X st_insert(groupHashTable, (int)group->groupid, (char *)group);
- X}
- X
- X/* groupDelete -- remove a group structure from the lookup table
- X */
- Xstatic Bool
- XgroupDelete(grpid)
- XGroupID grpid;
- X{
- X Group *oldGrp;
- X GroupID tmpGrp = grpid;
- X GroupID *tmpGrpPtr = &tmpGrp;
- X
- X return st_delete(groupHashTable, (char *)tmpGrpPtr, (char *)&oldGrp);
- X}
- X
- X/***************************************************************************
- X* Global functions
- X***************************************************************************/
- X
- X/*
- X * GroupInit -- initialises the hash table used to map group id's to
- X * group structures.
- X */
- Xvoid
- XGroupInit()
- X{
- X groupHashTable = st_init_table(groupCompare, groupHash);
- X}
- X
- X
- X/* GroupApply -- applies a function to each part of the group identified
- X * in the mask; as with any apply function, when the function returns
- X * a non-NULL value application stops and that value is returned.
- X */
- Xvoid *
- XGroupApply(grpid, func, closure, mask)
- XGroupID grpid;
- XGroupFunc func;
- Xvoid *closure;
- Xunsigned int mask;
- X{
- X Group *group;
- X void *res = NULL;
- X
- X group = GroupLookup(grpid);
- X if (group == NULL)
- X return NULL;
- X
- X if ((mask & GROUP_LEADER) && (group->leader != NULL))
- X {
- X res = (func)(group->leader, closure);
- X }
- X
- X if ((mask & GROUP_DEPENDENT) && (group->dependents != NULL) &&
- X (res == NULL))
- X {
- X res = ListApply(group->dependents,func,closure);
- X }
- X
- X if ((mask & GROUP_INDEPENDENT) && (group->independents != NULL) &&
- X (res == NULL))
- X {
- X res = ListApply(group->independents,func,closure);
- X }
- X
- X return res;
- X}
- X
- X/* GroupLookup -- given a GroupID, returns the associated group structure,
- X * or NULL if there is none.
- X */
- XGroup *
- XGroupLookup(group)
- XGroupID group;
- X{
- X Group *tmp = NULL;
- X
- X st_lookup(groupHashTable, group, &tmp);
- X return tmp;
- X}
- X
- X/* GroupAdd -- adds a client to the named group, creating the group if need be.
- X * The kind of client is specified in the mask field. Returns True
- X * if the client was successfully added.
- X */
- XBool
- XGroupAdd(grpid, cli, mask)
- XGroupID grpid;
- XClient *cli;
- Xunsigned int mask;
- X{
- X Group *group;
- X unsigned int currmask;
- X
- X group = GroupLookup(grpid);
- X if (group == NULL)
- X {
- X group = MemNew(Group);
- X group->groupid = grpid;
- X groupInsert(group);
- X currmask = 0;
- X }
- X else
- X {
- X currmask = groupFindCli(group, cli, NULL);
- X }
- X
- X if (mask & GROUP_LEADER)
- X {
- X if ((currmask == 0) || (group->leader == cli))
- X {
- X group->leader = cli;
- X return True;
- X }
- X else
- X return False;
- X }
- X else if (mask & GROUP_DEPENDENT)
- X {
- X if (currmask != 0)
- X return False;
- X group->dependents = ListCons(cli,group->dependents);
- X }
- X else if (mask & GROUP_INDEPENDENT)
- X {
- X if (currmask != 0)
- X return False;
- X group->independents = ListCons(cli,group->independents);
- X }
- X return True;
- X}
- X
- X/* GroupRemove -- removes a client from the group. If the group becomes empty
- X * it is deleted. Returns True if the client was successfully deleted.
- X */
- XBool
- XGroupRemove(grpid,cli)
- XGroupID grpid;
- XClient *cli;
- X{
- X Group *group;
- X unsigned int mask;
- X List **plist;
- X
- X group = GroupLookup(grpid);
- X if (group == NULL)
- X return False;
- X
- X mask = groupFindCli(group, cli, &plist);
- X if (mask == GROUP_LEADER)
- X {
- X group->leader = NULL;
- X }
- X else if ((mask == GROUP_DEPENDENT) || (mask == GROUP_INDEPENDENT))
- X {
- X ListDestroyCell(plist);
- X }
- X else
- X {
- X return False;
- X }
- X if ((group->leader == NULL) && (group->dependents == NULL) &&
- X (group->independents == NULL))
- X {
- X groupDelete(group->groupid);
- X MemFree(group);
- X }
- X return True;
- X}
- X
- X
- X/* GroupIsLeader -- returns whether a particular client is leader of a group
- X * If the group hasn't been registered yet, assume that this client is
- X * its leader.
- X */
- XBool
- XGroupIsLeader(grpid, cli)
- XGroupID grpid;
- XClient *cli;
- X{
- X Group *group;
- X
- X group = GroupLookup(grpid);
- X if (group == NULL)
- X return True;
- X return (group->leader == cli);
- X}
- X
- X
- X/* GroupLeader -- returns the leader of a group
- X */
- XClient *
- XGroupLeader(grpid)
- XGroupID grpid;
- X{
- X Group *group;
- X
- X group = GroupLookup(grpid);
- X if (group == NULL)
- X return NULL;
- X else
- X return group->leader;
- X}
- END_OF_FILE
- if test 6503 -ne `wc -c <'group.c'`; then
- echo shar: \"'group.c'\" unpacked with wrong size!
- fi
- # end of 'group.c'
- fi
- if test -f 'resources.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'resources.h'\"
- else
- echo shar: Extracting \"'resources.h'\" \(1013 characters\)
- sed "s/^X//" >'resources.h' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)resources.h 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)resources.h 26.16 91/09/14 SMI"
- X *
- X */
- X
- X#ifndef _OLWM_RESOURCES_H
- X#define _OLWM_RESOURCES_H
- X
- X#include <X11/Xresource.h>
- X
- X/* maximum length of fully-specified instance/class name */
- X#define MAX_NAME 100
- X#define MAX_CLASS 100
- X
- X#define BASICPTR 0
- X#define MOVEPTR 1
- X#define BUSYPTR 2
- X#define ICONPTR 3
- X#define RESIZEPTR 4
- X#define MENUPTR 5
- X#define QUESTIONPTR 6
- X#define TARGETPTR 7
- X#define PANPTR 8
- X#define NUM_CURSORS 9 /* number of pointers supported */
- X
- Xextern XrmQuark TopClassQ;
- Xextern XrmQuark TopInstanceQ;
- Xextern XrmQuark OpenWinQ;
- Xextern XrmQuark OlwmQ;
- Xextern XrmDatabase OlwmDB;
- X
- Xextern void InitGlobals();
- Xextern void UpdateGlobals();
- X
- X#ifdef OW_I18N_L3
- Xextern void EffectOLLC();
- X#endif /* OW_I18N_L3 */
- X
- X#endif /* _OLWM_RESOURCES_H */
- END_OF_FILE
- if test 1013 -ne `wc -c <'resources.h'`; then
- echo shar: \"'resources.h'\" unpacked with wrong size!
- fi
- # end of 'resources.h'
- fi
- if test -f 'st.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'st.c'\"
- else
- echo shar: Extracting \"'st.c'\" \(8091 characters\)
- sed "s/^X//" >'st.c' <<'END_OF_FILE'
- X/* This is a general purpose hash table package written by Peter Moore @ UCB. */
- X#ident "@(#)st.c 26.6 91/09/14 SMI"
- X
- X#include <stdio.h>
- X#include "st.h"
- X#include "mem.h"
- X
- X
- X#define max(a,b) ((a) > (b) ? (a) : (b))
- X#define nil(type) ((type *) 0)
- X#define alloc(type) (type *)MemAlloc((unsigned)sizeof(type))
- X#define Calloc(n,s) (char *)MemCalloc((n),(s))
- X
- X /*
- X * DEFAULT_MAX_DENSITY is the default for the largest we allow the
- X * average number of items per bin before increasing the number of
- X * bins
- X *
- X * DEFAULT_INIT_TABLE_SIZE is the default for the number of bins
- X * allocated initially
- X *
- X * DEFAULT_GROW_FACTOR is the amount the hash table is expanded after
- X * the density has reached max_density
- X */
- X
- X#define EQUAL(func, x, y) \
- X ((func == ST_NUMCMP) ? ((x) == (y)) : ((*func)((x), (y)) == 0))
- X
- X/*#define do_hash(key, table) (*table->hash)(key, table->num_bins)*/
- X
- X#define do_hash(key, table)\
- X ((table->hash == ST_PTRHASH) ? (((int) (key) >> 2) % table->num_bins) :\
- X (table->hash == ST_NUMHASH) ? ((int) (key) % table->num_bins) :\
- X (*table->hash)((key), table->num_bins))
- X
- Xst_table *st_init_table_with_params(compare, hash, size, density, grow_factor,
- X reorder_flag)
- Xint (*compare)();
- Xint (*hash)();
- Xint size;
- Xint density;
- Xdouble grow_factor;
- Xint reorder_flag;
- X{
- X st_table *new;
- X
- X new = alloc(st_table);
- X new->compare = compare;
- X new->hash = hash;
- X new->num_entries = 0;
- X new->max_density = density;
- X new->grow_factor = grow_factor;
- X new->reorder_flag = reorder_flag;
- X new->num_bins = size;
- X new->bins =
- X (st_table_entry **) Calloc((unsigned)size, sizeof(st_table_entry *));
- X return new;
- X}
- X
- Xst_table *st_init_table(compare, hash)
- Xint (*compare)();
- Xint (*hash)();
- X{
- X return st_init_table_with_params(compare, hash, ST_DEFAULT_INIT_TABLE_SIZE,
- X ST_DEFAULT_MAX_DENSITY,
- X ST_DEFAULT_GROW_FACTOR,
- X ST_DEFAULT_REORDER_FLAG);
- X}
- X
- Xst_free_table(table)
- Xst_table *table;
- X{
- X register st_table_entry *ptr, *next;
- X int i;
- X
- X for(i = 0; i < table->num_bins ; i++) {
- X ptr = table->bins[i];
- X while (ptr != nil(st_table_entry)) {
- X next = ptr->next;
- X free((char *) ptr);
- X ptr = next;
- X }
- X }
- X free((char *) table->bins);
- X free((char *) table);
- X}
- X
- X#define PTR_NOT_EQUAL(table, ptr, key)\
- X(ptr != nil(st_table_entry) && !EQUAL(table->compare, key, (ptr)->key))
- X
- X#define FIND_ENTRY(table, ptr, hashval)\
- Xptr = (table)->bins[hashval];\
- Xif (PTR_NOT_EQUAL(table, ptr, key)) {\
- X while (PTR_NOT_EQUAL(table, ptr->next, key)) {\
- X ptr = ptr->next;\
- X }\
- X if (ptr->next != nil(st_table_entry) && (table)->reorder_flag) {\
- X st_table_entry *_tmp = (ptr)->next;\
- X (ptr)->next = (ptr)->next->next;\
- X _tmp->next = (table)->bins[hashval];\
- X (table)->bins[hashval] = _tmp;\
- X ptr = _tmp;\
- X } else {\
- X ptr = ptr->next;\
- X }\
- X}
- X
- Xst_lookup(table, key, value)
- Xst_table *table;
- Xregister char *key;
- Xchar **value;
- X{
- X int hash_val;
- X register st_table_entry *ptr;
- X
- X hash_val = do_hash(key, table);
- X
- X FIND_ENTRY(table, ptr, hash_val);
- X
- X if (ptr == nil(st_table_entry)) {
- X return 0;
- X } else {
- X if (value != nil(char *)) *value = ptr->record;
- X return 1;
- X }
- X}
- X
- X#define ADD_DIRECT(table, key, value, hash_val, new)\
- X{\
- X if (table->num_entries/table->num_bins > table->max_density) {\
- X rehash(table);\
- X hash_val = do_hash(key,table);\
- X }\
- X \
- X new = alloc(st_table_entry);\
- X \
- X new->key = key;\
- X new->record = value;\
- X new->next = table->bins[hash_val];\
- X table->bins[hash_val] = new;\
- X table->num_entries++;\
- X}
- X
- Xst_insert(table, key, value)
- Xregister st_table *table;
- Xregister char *key;
- Xchar *value;
- X{
- X int hash_val;
- X st_table_entry *new;
- X register st_table_entry *ptr;
- X
- X hash_val = do_hash(key, table);
- X
- X FIND_ENTRY(table, ptr, hash_val);
- X
- X if (ptr == nil(st_table_entry)) {
- X ADD_DIRECT(table,key,value,hash_val,new);
- X return 0;
- X } else {
- X ptr->record = value;
- X return 1;
- X }
- X}
- X
- Xst_add_direct(table, key, value)
- Xst_table *table;
- Xchar *key;
- Xchar *value;
- X{
- X int hash_val;
- X st_table_entry *new;
- X
- X hash_val = do_hash(key, table);
- X ADD_DIRECT(table, key, value, hash_val, new);
- X}
- X
- Xst_find_or_add(table, key, slot)
- Xst_table *table;
- Xchar *key;
- Xchar ***slot;
- X{
- X int hash_val;
- X st_table_entry *new, *ptr;
- X
- X hash_val = do_hash(key, table);
- X
- X FIND_ENTRY(table, ptr, hash_val);
- X
- X if (ptr == nil(st_table_entry)) {
- X ADD_DIRECT(table, key, (char *)0, hash_val, new)
- X if (slot != nil(char **)) *slot = &new->record;
- X return 0;
- X } else {
- X if (slot != nil(char **)) *slot = &ptr->record;
- X return 1;
- X }
- X}
- X
- Xstatic rehash(table)
- Xregister st_table *table;
- X{
- X register st_table_entry *ptr, *next, **old_bins = table->bins;
- X int i, old_num_bins = table->num_bins, hash_val;
- X
- X table->num_bins = table->grow_factor*old_num_bins;
- X
- X if (table->num_bins%2 == 0) {
- X table->num_bins += 1;
- X }
- X
- X table->num_entries = 0;
- X table->bins =
- X (st_table_entry **) Calloc((unsigned) table->num_bins,
- X sizeof(st_table_entry *));
- X
- X for(i = 0; i < old_num_bins ; i++) {
- X ptr = old_bins[i];
- X while (ptr != nil(st_table_entry)) {
- X next = ptr->next;
- X hash_val = do_hash(ptr->key, table);
- X ptr->next = table->bins[hash_val];
- X table->bins[hash_val] = ptr;
- X table->num_entries++;
- X ptr = next;
- X }
- X }
- X free((char *) old_bins);
- X}
- X
- Xst_table *st_copy(old_table)
- Xst_table *old_table;
- X{
- X st_table *new_table;
- X st_table_entry *ptr, *new;
- X int i, num_bins = old_table->num_bins;
- X
- X new_table = alloc(st_table);
- X if (new_table == nil(st_table)) {
- X return nil(st_table);
- X }
- X
- X *new_table = *old_table;
- X new_table->bins =
- X (st_table_entry **) Calloc((unsigned) num_bins, sizeof(st_table_entry *));
- X
- X if (new_table->bins == nil(st_table_entry *)) {
- X free((char *) new_table);
- X return nil(st_table);
- X }
- X
- X for(i = 0; i < num_bins ; i++) {
- X new_table->bins[i] = nil(st_table_entry);
- X ptr = old_table->bins[i];
- X while (ptr != nil(st_table_entry)) {
- X new = alloc(st_table_entry);
- X if (new == nil(st_table_entry)) {
- X free((char *) new_table->bins);
- X free((char *) new_table);
- X return nil(st_table);
- X }
- X *new = *ptr;
- X new->next = new_table->bins[i];
- X new_table->bins[i] = new;
- X ptr = ptr->next;
- X }
- X }
- X return new_table;
- X}
- X
- Xst_delete(table, key, value)
- Xregister st_table *table;
- Xregister char **key;
- Xchar **value;
- X{
- X int hash_val;
- X st_table_entry *tmp;
- X register st_table_entry *ptr;
- X
- X hash_val = do_hash(*key, table);
- X
- X ptr = table->bins[hash_val];
- X
- X if (ptr == nil(st_table_entry)) {
- X *value = nil(char);
- X return 0;
- X }
- X
- X if (EQUAL(table->compare, *key, ptr->key)) {
- X table->bins[hash_val] = ptr->next;
- X table->num_entries--;
- X if (value != nil(char *)) *value = ptr->record;
- X *key = ptr->key;
- X free((char *) ptr);
- X return 1;
- X }
- X
- X for(; ptr->next != nil(st_table_entry); ptr = ptr->next) {
- X if (EQUAL(table->compare, ptr->next->key, *key)) {
- X tmp = ptr->next;
- X ptr->next = ptr->next->next;
- X if (value != nil(char *)) *value = tmp->record;
- X *key = tmp->key;
- X free((char *) tmp);
- X return 1;
- X }
- X }
- X
- X return 0;
- X}
- X
- Xst_foreach(table, func, arg)
- Xst_table *table;
- Xenum st_retval (*func)();
- Xchar *arg;
- X{
- X st_table_entry *ptr, *last, *tmp;
- X enum st_retval retval;
- X int i;
- X
- X for(i = 0; i < table->num_bins; i++) {
- X last = nil(st_table_entry);
- X for(ptr = table->bins[i]; ptr != nil(st_table_entry);) {
- X retval = (*func)(ptr->key, ptr->record, arg);
- X switch (retval) {
- X case ST_CONTINUE:
- X last = ptr;
- X ptr = ptr->next;
- X break;
- X case ST_STOP:
- X return;
- X case ST_DELETE:
- X tmp = ptr;
- X if (last == nil(st_table_entry)) {
- X table->bins[i] = ptr->next;
- X } else {
- X last->next = ptr->next;
- X }
- X ptr = ptr->next;
- X free((char *) tmp);
- X }
- X }
- X }
- X}
- X
- Xst_strhash(string, modulus)
- Xregister char *string;
- Xint modulus;
- X{
- X register int val = 0;
- X register int c;
- X
- X while ((c = *string++) != '\0') {
- X val = val*997 + c;
- X }
- X
- X return ((val < 0) ? -val : val)%modulus;
- X}
- END_OF_FILE
- if test 8091 -ne `wc -c <'st.c'`; then
- echo shar: \"'st.c'\" unpacked with wrong size!
- fi
- # end of 'st.c'
- fi
- if test -f 'winmenu.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'winmenu.c'\"
- else
- echo shar: Extracting \"'winmenu.c'\" \(7303 characters\)
- sed "s/^X//" >'winmenu.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)winmenu.c 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)winmenu.c 26.14 91/09/14 SMI"
- X *
- X */
- X
- X#include <errno.h>
- X#include <stdio.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xatom.h>
- X#include <olgx/olgx.h>
- X
- X#include "i18n.h"
- X#include "ollocale.h"
- X#include "mem.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "menu.h"
- X#include "globals.h"
- X
- X/***************************************************************************
- X* private data
- X***************************************************************************/
- X
- X/* function vector for menu windows */
- Xstatic ClassMenu classMenu;
- X
- X#define MENU_EVENT_MASK (PropertyChangeMask|SubstructureNotifyMask)
- X#define MENU_ATTR_EVENT_MASK (ButtonPressMask|ExposureMask)
- X
- X#define MENU_SHADOW_OFFSET (10);
- X
- X/***************************************************************************
- X* private functions
- X***************************************************************************/
- X
- X/* REMIND - none yet */
- X
- X/***************************************************************************
- X* private event functions
- X***************************************************************************/
- X
- X/*
- X * eventButtonPress - a button has gone down.
- X */
- Xstatic int
- XeventButtonPress(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinMenu *winInfo;
- X{
- X /* REMIND - placeholder for future */
- X}
- X
- X/*
- X * eventButtonRelease - a button has gone up
- X */
- Xstatic int
- XeventButtonRelease(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinMenu *winInfo;
- X{
- X /* REMIND - placeholder for future */
- X}
- X
- X/*
- X * eventKeyPress - a key has gone down
- X */
- Xstatic int
- XeventKeyPress(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinMenu *winInfo;
- X{
- X /* REMIND - mouseless operation */
- X}
- X
- X/*
- X * eventKeyRelease - a key has gone up
- X */
- Xstatic int
- XeventKeyRelease(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinMenu *winInfo;
- X{
- X /* REMIND - mouseless operation */
- X}
- X
- X/*
- X * eventMotionNotify - mouse moved
- X */
- Xstatic int
- XeventMotionNotify(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinMenu *winInfo;
- X{
- X /* REMIND - placeholder for future */
- X}
- X
- X/*
- X * destroyMenu -- destroy the menu window resources and free any allocated
- X * data.
- X */
- Xstatic int
- XdestroyMenu(dpy, winInfo)
- X Display *dpy;
- X WinMenu *winInfo;
- X{
- X XUndefineCursor(dpy, winInfo->core.self);
- X XDestroyWindow(dpy, winInfo->core.self);
- X#ifdef SHADOW
- X XDestroyWindow(dpy, winInfo->menu.shadow);
- X#endif /* SHADOW */
- X MemFree(winInfo);
- X}
- X
- X
- X/***************************************************************************
- X* global functions
- X***************************************************************************/
- X
- X/*
- X * MakeMenu -- create the WinMenu structure and windows but does not
- X * map them.
- X */
- XWinMenu *
- XMakeMenu(dpy, winInfo)
- X Display *dpy;
- X WinGeneric *winInfo;
- X{
- X WinMenu *w;
- X Window win;
- X unsigned long valuemask;
- X XSetWindowAttributes attributes;
- X Client *cli = winInfo->core.client;
- X
- X /* create the associated structure */
- X w = MemNew(WinMenu);
- X w->class = &classMenu;
- X w->core.kind = WIN_MENU;
- X w->core.children = NULL;
- X w->core.client = cli;
- X w->core.x = 0;
- X w->core.y = 0;
- X w->core.width = 1;
- X w->core.height = 1;
- X /* REMIND - is dirtyconfig necessary??? */
- X w->core.dirtyconfig = CWX|CWY|CWWidth|CWHeight;
- X w->core.exposures = NULL;
- X w->core.helpstring = (char *)0;
- X
- X /* Menu window. */
- X attributes.event_mask = MENU_ATTR_EVENT_MASK;
- X attributes.save_under = DoesSaveUnders(
- X ScreenOfDisplay(dpy,cli->screen));
- X attributes.border_pixel = 0;
- X attributes.colormap = cli->scrInfo->colormap;
- X valuemask = CWEventMask | CWSaveUnder | CWBorderPixel | CWColormap;
- X
- X win = XCreateWindow(dpy, WinRootID(winInfo),
- X w->core.x, w->core.y,
- X w->core.width, w->core.height,
- X 0,
- X WinDepth(winInfo),
- X InputOutput,
- X WinVisual(winInfo),
- X valuemask,
- X &attributes);
- X w->core.self = win;
- X
- X WIInstallInfo(w);
- X
- X#ifdef SHADOW
- X /* REMIND - there is no pixmapGray - what to use really??? */
- X attributes.background_pixmap = pixmapGray;
- X attributes.save_under = DoesSaveUnders(cli->screen);
- X w->shadow = XCreateWindow(dpy, WinRootID(winInfo),
- X 0, 0, 1, 1,
- X 0,
- X WinDepth(winInfo),
- X InputOutput,
- X WinVisual(winInfo),
- X CWBackPixmap | CWSaveUnder,
- X &attributes);
- X#endif /* SHADOW */
- X
- X XDefineCursor( dpy, win, GRV.MenuPointer );
- X
- X return w;
- X}
- X
- X/*
- X * MapMenuWindow - Configures (sizes) and maps the WinMenu windows
- X */
- Xvoid
- XMapMenuWindow(dpy,winInfo,menuInfo)
- X Display *dpy;
- X WinMenu *winInfo;
- X MenuInfo *menuInfo;
- X{
- X XWindowChanges changes;
- X
- X /* position, size and map menu window */
- X winInfo->core.x = menuInfo->menuX;
- X winInfo->core.y = menuInfo->menuY;
- X winInfo->core.width = menuInfo->menuWidth;
- X winInfo->core.height = menuInfo->menuHeight;
- X changes.x = winInfo->core.x;
- X changes.y = winInfo->core.y;
- X changes.width = winInfo->core.width;
- X changes.height = winInfo->core.height;
- X ConfigureWindow(dpy,winInfo,
- X CWX|CWY|CWWidth|CWHeight,&changes);
- X MapRaised(winInfo);
- X
- X#ifdef SHADOW
- X
- X /* map shadow below menu window */
- X changes.x = menuInfo.menuX + MENU_SHADOW_OFFSET;
- X changes.y = menuInfo.menuY + MENU_SHADOW_OFFSET;
- X changes.sibling = winInfo->core.self;
- X change.stack_mode = Below;
- X ConfigureWindow(dpy,winInfo,
- X CWX|CWY|CWWidth|CWHeight|CWStackMode|CWSibling,&changes);
- X#endif /* SHADOW */
- X
- X /* save the menuinfo */
- X winInfo->menuInfo = menuInfo;
- X
- X DrawMenu(dpy,menuInfo);
- X}
- X
- X/*
- X * UnmapMenuWindow - take down WinMenu windows
- X */
- Xvoid
- XUnmapMenuWindow(dpy,winInfo)
- X Display *dpy;
- X WinMenu *winInfo;
- X{
- X UnmapWindow(winInfo);
- X#ifdef SHADOW
- X XUnmapWindow(dpy,winInfo->shadow);
- X#endif /* SHADOW */
- X winInfo->menuInfo = (MenuInfo *)NULL;
- X}
- X
- X
- Xint
- XMenuEventExpose(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinGeneric *winInfo;
- X{
- X MenuInfo *mInfo = NULL;
- X
- X if (winInfo->core.kind == WIN_MENU)
- X mInfo = ((WinMenu *) winInfo)->menuInfo;
- X else
- X mInfo = ((WinPinMenu *) winInfo)->menuInfo;
- X
- X if (mInfo == NULL) /*not yet reparented*/
- X WinEventExpose(dpy, event, winInfo);
- X else {
- X SetMenuRedrawHints(dpy, event, mInfo);
- X
- X if (event->xexpose.count == 0)
- X DrawMenuWithHints(dpy, mInfo);
- X }
- X}
- X
- X/*
- X * drawMenu -- draw the menu window
- X */
- Xint
- XMenuEventDrawMenu(dpy, winInfo)
- X Display *dpy;
- X WinGeneric *winInfo;
- X{
- X MenuInfo *mInfo = NULL;
- X
- X if (winInfo->core.kind == WIN_MENU)
- X mInfo = ((WinMenu *) winInfo)->menuInfo;
- X else
- X mInfo = ((WinPinMenu *) winInfo)->menuInfo;
- X
- X if (mInfo)
- X DrawMenu(dpy, mInfo);
- X}
- X
- X
- X/*
- X * MenuInit - initialize WinMenu class functions
- X */
- X/*ARGSUSED*/
- Xvoid
- XMenuInit(dpy)
- XDisplay *dpy;
- X{
- X classMenu.core.kind = WIN_MENU;
- X classMenu.core.xevents[ButtonPress] = eventButtonPress;
- X classMenu.core.xevents[ButtonRelease] = eventButtonRelease;
- X classMenu.core.xevents[MotionNotify] = eventMotionNotify;
- X classMenu.core.xevents[KeyPress] = eventKeyPress;
- X classMenu.core.xevents[KeyRelease] = eventKeyRelease;
- X classMenu.core.xevents[Expose] = MenuEventExpose;
- X classMenu.core.drawfunc = MenuEventDrawMenu;
- X classMenu.core.destroyfunc = destroyMenu;
- X classMenu.core.heightfunc = NULL;
- X classMenu.core.widthfunc = NULL;
- X}
- END_OF_FILE
- if test 7303 -ne `wc -c <'winmenu.c'`; then
- echo shar: \"'winmenu.c'\" unpacked with wrong size!
- fi
- # end of 'winmenu.c'
- fi
- if test -f 'winnofoc.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'winnofoc.c'\"
- else
- echo shar: Extracting \"'winnofoc.c'\" \(7314 characters\)
- sed "s/^X//" >'winnofoc.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)winnofoc.c 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)winnofoc.c 26.17 91/09/14 SMI"
- X *
- X */
- X
- X#include <errno.h>
- X#include <stdio.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xatom.h>
- X#include <olgx/olgx.h>
- X
- X#include "i18n.h"
- X#include "ollocale.h"
- X#include "mem.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "globals.h"
- X
- Xextern unsigned int FindModifierMask();
- Xextern Atom AtomProtocols;
- Xextern Atom AtomTakeFocus;
- Xextern void ClientSetCurrent();
- X
- X/***************************************************************************
- X* global data
- X***************************************************************************/
- X
- XWindow NoFocusWin = NULL;
- XWinNoFocus *NoFocusWinInfo;
- X
- X/***************************************************************************
- X* private data
- X***************************************************************************/
- X
- Xstatic ClassNoFocus classNoFocus;
- X
- X/***************************************************************************
- X* private functions
- X***************************************************************************/
- X
- X/*
- X * DestroyNoFocus -- destroy the no-focus window and free any allocated
- X * data.
- X */
- Xstatic int
- XdestroyNoFocus(dpy, winInfo)
- XDisplay *dpy;
- XWinGeneric *winInfo;
- X{
- X /* free our data and throw away window */
- X DestroyWindow(winInfo);
- X MemFree(winInfo);
- X}
- X
- X
- X/*
- X * eventClientMessage - handle WM_TAKE_FOCUS messages. This is a vestige of a
- X * previous focus-handling scheme. However, it remains, in case it becomes
- X * useful at some time for the no-focus window to respond to WM_TAKE_FOCUS
- X * messages.
- X */
- Xstatic int
- XeventClientMessage(dpy, event, winInfo)
- X Display *dpy;
- X XEvent *event;
- X WinNoFocus *winInfo;
- X{
- X if (event->xclient.message_type == AtomProtocols &&
- X event->xclient.data.l[0] == AtomTakeFocus &&
- X event->xclient.format == 32)
- X {
- X NoFocusTakeFocus(dpy, event->xclient.data.l[1],
- X winInfo->core.client->scrInfo);
- X }
- X}
- X
- X
- X/*
- X * eventSelectionNotify - someone else has asked for the selection value
- X */
- Xstatic int
- XeventSelectionNotify(dpy, pEvent, winInfo)
- X Display *dpy;
- X XEvent *pEvent;
- X WinNoFocus *winInfo;
- X{
- X /*
- X * We get this event from the owner of the selection if we had made a
- X * XConvertSelection call. Presently, olwm never makes any
- X * XConvertSelection requests, so we don't have to worry about a
- X * SelectionNotify event.
- X */
- X}
- X
- X
- X/*
- X * eventSelectionRequest - someone else has asked for the selection value
- X */
- Xstatic int
- XeventSelectionRequest(dpy, pEvent, winInfo)
- X Display *dpy;
- X XEvent *pEvent;
- X WinNoFocus *winInfo;
- X{
- X SelectionResponse((XSelectionRequestEvent *)pEvent);
- X}
- X
- X
- X/*
- X * eventSelectionClear - someone else has asked to be the selection owner
- X */
- Xstatic int
- XeventSelectionClear(dpy, pEvent, winInfo)
- X Display *dpy;
- X XEvent *pEvent;
- X WinNoFocus *winInfo;
- X{
- X /*
- X * Someone else has asked to be the selection owner.
- X * Clear our list of selected windows.
- X */
- X ClearSelections(dpy);
- X}
- X
- X
- X/***************************************************************************
- X* global functions
- X***************************************************************************/
- X
- X/*
- X * MakeNoFocus -- create the no-focus windows to a window. Return a
- X * WinGeneric structure.
- X */
- XWinGeneric *
- XMakeNoFocus(dpy, par)
- XDisplay *dpy;
- XWinGeneric *par;
- X{
- X XSetWindowAttributes attributes;
- X WinNoFocus *w;
- X
- X /* create the window */
- X attributes.event_mask = KeyPressMask;
- X attributes.override_redirect = True;
- X NoFocusWin = XCreateWindow(dpy, par->core.self,
- X -10, -10,
- X 10, 10 ,
- X 0,
- X 0,
- X InputOnly,
- X CopyFromParent,
- X CWEventMask | CWOverrideRedirect,
- X &attributes);
- X XMapWindow(dpy, NoFocusWin);
- X
- X /* create the associated structure */
- X w = MemNew(WinNoFocus);
- X w->core.self = NoFocusWin;
- X w->core.kind = WIN_NOFOCUS;
- X w->class = &classNoFocus;
- X w->core.parent = par;
- X w->core.children = NULL;
- X w->core.client = par->core.client;
- X w->core.x = -10;
- X w->core.y = -10;
- X w->core.width = 10;
- X w->core.height = 10;
- X w->core.dirtyconfig = False;
- X w->core.exposures = NULL;
- X w->core.helpstring = (char *)NULL; /* no help */
- X
- X /* register the window */
- X WIInstallInfo(w);
- X
- X /* set the focus to the NoFocusWin */
- X NoFocusWinInfo = w;
- X
- X return w;
- X}
- X
- X/*
- X * Handle a key press in the no focus window. If its a standard Virtual
- X * Desktop function -- up, down, etc. -- then execute it, otherwise beep
- X */
- Xstatic int
- XNoFocusKey(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinGeneric *winInfo;
- X
- X{
- X if (!GRV.ArrowInRoot || !KeyMoveVDM(dpy, event))
- X NoFocusEventBeep(dpy, event, winInfo);
- X}
- X
- Xvoid
- XNoFocusInit(dpy)
- XDisplay *dpy;
- X{
- X classNoFocus.core.kind = WIN_NOFOCUS;
- X classNoFocus.core.xevents[ButtonPress] = NoFocusEventBeep;
- X classNoFocus.core.xevents[ButtonRelease] = NoFocusEventBeep;
- X classNoFocus.core.xevents[KeyPress] = NoFocusKey; /*NoFocusEventBeep;
- X classNoFocus.core.xevents[KeyRelease] = NoFocusEventBeep; */
- X classNoFocus.core.xevents[ClientMessage] = eventClientMessage;
- X classNoFocus.core.xevents[SelectionNotify] = eventSelectionNotify;
- X classNoFocus.core.xevents[SelectionRequest] = eventSelectionRequest;
- X classNoFocus.core.xevents[SelectionClear] = eventSelectionClear;
- X classNoFocus.core.focusfunc = NULL;
- X classNoFocus.core.drawfunc = NULL;
- X classNoFocus.core.destroyfunc = destroyNoFocus;
- X classNoFocus.core.selectfunc = NULL;
- X classNoFocus.core.newconfigfunc = NULL;
- X classNoFocus.core.newposfunc = NULL;
- X classNoFocus.core.setconfigfunc = NULL;
- X classNoFocus.core.createcallback = NULL;
- X classNoFocus.core.heightfunc = NULL;
- X classNoFocus.core.widthfunc = NULL;
- X}
- X
- X
- X/*
- X * Set the focus to the NoFocus window. If colormap installation is tracking
- X * the focus, install and lock the default colormap for this screen.
- X */
- Xvoid
- XNoFocusTakeFocus(dpy,evtime,scrInfo)
- XDisplay *dpy;
- XTime evtime;
- XScreenInfo *scrInfo;
- X{
- X XSetInputFocus(dpy, NoFocusWin, RevertToParent, evtime);
- X ClientSetCurrent(NoFocusWinInfo->core.client);
- X ClientDefaultWindowState(dpy);
- X if (scrInfo != NULL && GRV.ColorTracksInputFocus)
- X InstallDefaultColormap(dpy, scrInfo->rootwin, True);
- X}
- X
- X/*
- X * NoFocusEventBeep -- beep on keyboard/mouse events for the no-focus window
- X * Also used by busy windows
- X */
- Xint
- XNoFocusEventBeep(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinGeneric *winInfo;
- X{
- X XEvent dummy;
- X
- X if (FindModifierMask(event->xkey.keycode) != 0)
- X return;
- X
- X XSync(dpy,0);
- X /*
- X * Discard pending keyboard and mouse events on this
- X * window, and then beep once.
- X */
- X while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
- X KeyPress,&dummy))
- X /*EMPTY*/
- X ;
- X while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
- X KeyRelease,&dummy))
- X /*EMPTY*/
- X ;
- X while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
- X ButtonPress,&dummy))
- X /*EMPTY*/
- X ;
- X while (XCheckTypedWindowEvent(dpy,winInfo->core.self,
- X ButtonRelease,&dummy))
- X /*EMPTY*/
- X ;
- X KeyBeep(dpy,event);
- X}
- END_OF_FILE
- if test 7314 -ne `wc -c <'winnofoc.c'`; then
- echo shar: \"'winnofoc.c'\" unpacked with wrong size!
- fi
- # end of 'winnofoc.c'
- fi
- if test -f 'winresize.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'winresize.c'\"
- else
- echo shar: Extracting \"'winresize.c'\" \(8191 characters\)
- sed "s/^X//" >'winresize.c' <<'END_OF_FILE'
- X/*
- X * (c) Copyright 1989, 1990 Sun Microsystems, Inc. Sun design patents
- X * pending in the U.S. and foreign countries. See LEGAL_NOTICE
- X * file for terms of the license.
- X */
- X
- X#ident "@(#)winresize.c 1.1 olvwm version 1/3/92"
- X
- X/*
- X * Based on
- X#ident "@(#)winresize.c 26.22 91/09/14 SMI"
- X *
- X */
- X
- X#include <errno.h>
- X#include <stdio.h>
- X#include <X11/Xos.h>
- X#include <X11/Xlib.h>
- X#include <X11/Xutil.h>
- X#include <X11/Xatom.h>
- X#include <X11/keysym.h>
- X#include <olgx/olgx.h>
- X
- X#include "ollocale.h"
- X#include "i18n.h"
- X#include "mem.h"
- X#include "olwm.h"
- X#include "win.h"
- X#include "globals.h"
- X#include "events.h"
- X
- X/***************************************************************************
- X* global data
- X***************************************************************************/
- X
- Xextern int Resize_width, Resize_height;
- Xextern void FrameAllowEvents();
- X
- X/***************************************************************************
- X* private data
- X***************************************************************************/
- X
- Xstatic int whicholgx[] = {OLGX_UPPER_LEFT, OLGX_UPPER_RIGHT,
- X OLGX_LOWER_LEFT, OLGX_LOWER_RIGHT};
- Xstatic int whichgrav[] = {NorthWestGravity, NorthEastGravity,
- X SouthWestGravity, SouthEastGravity};
- X
- Xstatic ClassResize classResize;
- X
- X/***************************************************************************
- X* private functions
- X***************************************************************************/
- X
- X/*
- X * resizeCallback - restore the resize corner to its normal state
- X */
- Xstatic void
- XresizeCallback(dpy, winInfo)
- X Display *dpy;
- X WinResize *winInfo;
- X{
- X winInfo->depressed = False;
- X (WinFunc(winInfo,core.drawfunc))(dpy,winInfo);
- X}
- X
- X
- X/*
- X * eventButtonPress - handle button press events on the resize window
- X */
- Xstatic int
- XeventButtonPress(dpy, event, winInfo)
- XDisplay *dpy;
- XXEvent *event;
- XWinResize *winInfo;
- X{
- X unsigned int ignoremask =
- X ModMaskMap[MOD_CONSTRAIN] | ModMaskMap[MOD_INVERT];
- X
- X if (ResolveMouseBinding(dpy, event, ignoremask) != ACTION_SELECT) {
- X FrameAllowEvents(winInfo->core.client, event->xbutton.time);
- X return;
- X }
- X
- X /* draw depressed corner */
- X winInfo->depressed = True;
- X (WinFunc(winInfo,core.drawfunc))(dpy,winInfo);
- X
- X /* resize function will eat button release */
- X ClientResize(winInfo->core.client,event,winInfo->which,
- X resizeCallback,winInfo);
- X}
- X
- X
- X/*
- X * drawResize -- draw the resize window
- X */
- X/*ARGSUSED*/
- Xstatic int
- XdrawResize(dpy, winInfo)
- XDisplay *dpy;
- XWinResize *winInfo;
- X{
- X WhichResize which = winInfo->which;
- X GC drawForegroundGC = WinGC(winInfo,FOREGROUND_GC);
- X GC drawWindowGC = WinGC(winInfo,WINDOW_GC);
- X GC drawBusyGC = WinGC(winInfo,BUSY_GC);
- X Graphics_info *gis = WinGI(winInfo,NORMAL_GINFO);
- X
- X int focusLines; /* two lines or solid bar */
- X
- X if (winInfo->core.client->isFocus) {
- X drawWindowGC = WinGC(winInfo, INPUTFOCUS_GC);
- X gis = WinGI(winInfo, INPUTFOCUS_GINFO);
- X }
- X
- X focusLines = (GRV.FocusFollowsMouse ? 1 : 0) ^
- X (GRV.InvertFocusHighlighting ? 1 : 0);
- X
- X if ((which == upright) || (which == upleft))
- X {
- X if (winInfo->core.client->isBusy) {
- X XFillRectangle(dpy,winInfo->core.self,drawWindowGC,
- X (which==upleft)?(ResizeArm_Width(gis)):(0),
- X ResizeArm_Height(gis),
- X winInfo->core.width-ResizeArm_Width(gis),
- X winInfo->core.height-ResizeArm_Height(gis));
- X XFillRectangle(dpy,winInfo->core.self,drawBusyGC,
- X (which==upleft)?(ResizeArm_Width(gis)):(0),
- X ResizeArm_Height(gis),
- X winInfo->core.width-ResizeArm_Width(gis),
- X winInfo->core.height-ResizeArm_Height(gis));
- X } else if ((winInfo->core.client->isFocus) && !focusLines) {
- X if (Win3D(winInfo)) {
- X olgx_draw_box(gis, winInfo->core.self,
- X (which==upleft)?(ResizeArm_Width(gis)):(-2),
- X ResizeArm_Height(gis),
- X winInfo->core.width-ResizeArm_Width(gis)+2,
- X winInfo->core.height-ResizeArm_Height(gis)+2,
- X OLGX_INVOKED, True);
- X } else {
- X XFillRectangle(dpy,winInfo->core.self,
- X WinGC(winInfo,INPUTFOCUS_GC),
- X (which==upleft)?(ResizeArm_Width(gis)):(0),
- X ResizeArm_Height(gis),
- X winInfo->core.width-ResizeArm_Width(gis),
- X winInfo->core.height-ResizeArm_Height(gis));
- X }
- X } else {
- X XFillRectangle(dpy,winInfo->core.self,drawWindowGC,
- X (which==upleft)?(ResizeArm_Width(gis)):(0),
- X ResizeArm_Height(gis),
- X winInfo->core.width-ResizeArm_Width(gis),
- X winInfo->core.height-ResizeArm_Height(gis));
- X }
- X } else { /* lowleft or lowright */
- X XFillRectangle(dpy, winInfo->core.self, drawWindowGC,
- X (which==lowleft) ? (ResizeArm_Width(gis)) : 0, 0,
- X winInfo->core.width-ResizeArm_Width(gis),
- X winInfo->core.height-ResizeArm_Height(gis));
- X }
- X
- X if (!Win3D(winInfo) || !GRV.F3dResize)
- X gis = WinGI(winInfo, TEXT_GINFO);
- X
- X olgx_draw_resize_corner(gis, winInfo->core.self, 0, 0,
- X whicholgx[winInfo->which],
- X (winInfo->depressed)?(OLGX_INVOKED):(OLGX_NORMAL));
- X}
- X
- X
- X/*
- X * DestroyResize -- destroy the resize window resources and free any allocated
- X * data.
- X */
- Xstatic int
- XdestroyResize(dpy, winInfo)
- XDisplay *dpy;
- XWinGeneric *winInfo;
- X{
- X /* free our data and throw away window */
- X XUndefineCursor(dpy, winInfo->core.self);
- X DestroyWindow(winInfo);
- X MemFree(winInfo);
- X}
- X
- X/*
- X * focusselectResize - the focus or selection state has changed
- X */
- Xstatic int
- XfocusResize(dpy, winInfo, selected)
- XDisplay *dpy;
- XWinResize *winInfo;
- XBool selected;
- X{
- X (WinFunc(winInfo,core.drawfunc))(dpy, winInfo);
- X}
- X
- X/*
- X * widthfuncResize - recomputes the width of the resize window
- X */
- Xstatic int
- XwidthfuncResize(win, pxcre)
- XWinResize *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X return Resize_width;
- X}
- X
- X/*
- X * heightfuncResize - recomputes the width of the resize window
- X */
- Xstatic int
- XheightfuncResize(win, pxcre)
- XWinResize *win;
- XXConfigureRequestEvent *pxcre;
- X{
- X return Resize_height;
- X}
- X
- X/***************************************************************************
- X* global functions
- X***************************************************************************/
- X
- X/*
- X * MakeResize -- create the resize window. Return a WinGeneric structure.
- X */
- XWinResize *
- XMakeResize(dpy, par, which, x, y)
- XDisplay *dpy;
- XWinGeneric *par;
- XWhichResize which;
- Xint x,y;
- X{
- X WinResize *w;
- X Window win;
- X unsigned long valuemask;
- X XSetWindowAttributes attributes;
- X
- X attributes.event_mask =
- X ButtonPressMask | ButtonMotionMask | ButtonReleaseMask
- X | ExposureMask | OwnerGrabButtonMask;
- X attributes.win_gravity = whichgrav[which];
- X attributes.cursor = GRV.ResizePointer;
- X valuemask = CWEventMask | CWWinGravity | CWCursor;
- X
- X win = XCreateWindow(dpy, par->core.self,
- X x, y,
- X Resize_width, Resize_height,
- X 0,
- X CopyFromParent,
- X CopyFromParent,
- X CopyFromParent,
- X valuemask,
- X &attributes);
- X
- X /* create the associated structure */
- X w = MemNew(WinResize);
- X w->core.self = win;
- X w->class = &classResize;
- X w->core.kind = WIN_RESIZE;
- X WinAddChild(par,w);
- X w->core.children = NULL;
- X w->core.client = par->core.client;
- X w->core.x = x;
- X w->core.y = y;
- X w->core.width = Resize_width;
- X w->core.height = Resize_height;
- X w->core.dirtyconfig = CWX | CWY | CWWidth | CWHeight;
- X w->core.exposures = NULL;
- X w->which = which;
- X w->core.helpstring = "olwm:ResizeCorner";
- X
- X /* register the window */
- X WIInstallInfo(w);
- X
- X MapRaised(w);
- X
- X return w;
- X}
- X
- X
- X/* ResizeInit -- initialise values for the resize class
- X */
- Xvoid
- XResizeInit(dpy)
- XDisplay *dpy;
- X{
- X classResize.core.kind = WIN_RESIZE;
- X classResize.core.xevents[Expose] = WinEventExpose;
- X classResize.core.xevents[ButtonPress] = eventButtonPress;
- X classResize.core.focusfunc= focusResize;
- X classResize.core.drawfunc= drawResize;
- X classResize.core.destroyfunc = destroyResize;
- X classResize.core.selectfunc = NULL;
- X classResize.core.newconfigfunc = WinNewConfigFunc;
- X classResize.core.newposfunc = WinNewPosFunc;
- X classResize.core.setconfigfunc = WinSetConfigFunc;
- X classResize.core.createcallback = NULL;
- X classResize.core.heightfunc = heightfuncResize;
- X classResize.core.widthfunc = widthfuncResize;
- X}
- END_OF_FILE
- if test 8191 -ne `wc -c <'winresize.c'`; then
- echo shar: \"'winresize.c'\" unpacked with wrong size!
- fi
- # end of 'winresize.c'
- fi
- echo shar: End of archive 19 \(of 21\).
- cp /dev/null ark19isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 21 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Molecular Simulations, Inc. mail: dcmartin@postgres.berkeley.edu
- 796 N. Pastoria Avenue uucp: uwvax!ucbvax!dcmartin
- Sunnyvale, California 94086 at&t: 408/522-9236
-